
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
property-accessors
Advanced tools
A mixin for defining dynamic properties.
To define a basic property accessor, use the accessor
declaration. If you've
included the mixin into a class, you define a prototype property by calling
@::accessor
on its prototype.
PropertyAccessors = require 'property-accessors'
class Vehicle
PropertyAccessors.includeInto(this)
@::accessor 'type',
get: ->
switch @doorCount
when 4 then 'sedan' # i know this isn't strictly accurate
when 2 then 'coupe'
set: (type) ->
switch type
when 'sedan' then @doorCount = 4
when 'coupe' then @doorCount = 2
car = new Vehicle
car.doorCount = 2
car.type # => 'coupe'
You can define a class-level property by extending with the mixin rather than including it (which extends the prototype).
class Vehicle
PropertyAccessors.extend(this)
@accessor 'vehicleCount', get: -> @allVehicles.length
You can just pass a single function if you only want to define a getter:
class Vehicle
PropertyAccessors.includeInto(this)
@::accessor 'type', -> # ...
Lazy accessors call a function the first time a property is accessed. You are still free to overwrite this value by assigning the property explicitly.
class ScienceLab
PropertyAccessors.includeInto(this)
@::lazyAccessor 'crazyComputation', -> computeCrazyComputation()
Advised accessors allow you to call code before the reading or writing of a property value. If a property is being assigned, your advice function is called with the value being assigned and the old value.
class SpyStation
@advisedAccessor 'online',
get: -> @ensureAllSystemsNominal()
set: -> @ensureUserIsSpy()
station = new SpyStation
station.online = true # ensures user is a spy, then assigns true
station.online # ensures all systems are nominal, then returns true
FAQs
A mixin for declaring property accessors
The npm package property-accessors receives a total of 1,012 weekly downloads. As such, property-accessors popularity was classified as popular.
We found that property-accessors demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.